import itchat
import csv
itchat.auto_login()

friends = itchat.get_friends(update=True)[0:]

for i in friends:
    print(i)

f = open('C:\\Users\\27498\\Desktop\\hanhongwei.csv', 'w+', encoding='utf-8', newline='')
writer = csv.writer(f)
writer.writerow(['NickName', 'Sex', 'City', 'Province', 'Signature'])
for i in friends[1:]:
    writer.writerow([i['NickName'], i['Sex'], i['City'], i['Province'], i['Signature']])
# 获取数据
# f = open('C:/Users/274989/Desktop/1.csv', 'w+', encoding='utf-8', newline='')

# writer = csv.writer(f)f

# writer.writerow(['NickName', 'Sex', 'City', 'Province', 'Signature'])
# for i in friends[1:]:
#     writer.writerow([i['NickName'], i['Sex'], i['City'], i['Province'], i['Signature']])


# import pandas as pd

# df = pd.read_csv(open('c:/user/274989/Desktop/1.csv', encoding='utf-8'))
# df.head()
